package algorithms.nchance;
import storage.Block;
import configuration.Configuration;
/**
* @author Nodirjon Siddikov
*/
public class LocalCacheBlock
{
// instance variables
private int _size; //block size + tag size
private int _recirculationCount;
private Block _block; //pointer to the block that this cache block is hosting
//constructor
public LocalCacheBlock(Block block)
{
_block = block;
_size = _block.getSize() + Configuration.tagSize;
}
//get the block ID
public int getDiskBlockID()
{
return _block.getID();
}
//gets the cached disk block
public Block getDiskBlock()
{
return _block;
}
//gets the current recirculation count
public int getRecirulationCount()
{
return _recirculationCount;
}
//set the recirculation count of this block to n
public void setRecirculationCount(int reCrclCount)
{
_recirculationCount = reCrclCount;
}
//reset the recirculation count of this block to n
public void resetRecirculationCount()
{
_recirculationCount = Configuration.recirculationCount;
}
//decrement the recirculation count
public void decrementRecirculationCount()
{
_recirculationCount--;
}
//get the string representation of cache block
public String toString()
{
return "NChance CacheBlock : " + _block.getContent();
}
//get the size of the cache block
public int getSize()
{
return _size;
}
}